class PersonController {

    def scaffold = true

    def update = {
        def person = Person.get(params.id)
        if (person) {
            person.properties = params
            if (params."clique.id") {
                def clique = Clique.get(params."clique.id")
                person.addToCliques(clique)
            }

            if (!person.hasErrors() && person.save()) {
                flash.message = "Person $params.id updated"
                redirect(action: show, id: person.id)
            } else {
                render(view: 'edit', model: [person: person])
            }
        } else {
            flash.message = "Clique not found with id ${params.id}"
            redirect(action: edit, id: params.id)
        }
    }
}
